using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using YDSOO.Windows.Forms.Utils;

namespace YDSOO.Windows.Forms
{
    public partial class FrmBase : DevExpress.XtraEditors.XtraForm
    {
        int MouseDownX, MouseDownY;
        bool blnMoving;
        public FrmBase()
        {
            InitializeComponent();
        }

        private void closeButton1_Click(object sender, EventArgs e)
        {
            Close();
        }
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
                this.SelectNextControl(ActiveControl, true, true,true, true);
            base.OnKeyPress(e);
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left) return;
            blnMoving = true;
            MouseDownX = e.X;
            MouseDownY = e.Y;
        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (blnMoving)
                this.Location = new Point(
                    this.Location.X + (e.X - MouseDownX),
                    this.Location.Y + (e.Y - MouseDownY));
        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
                blnMoving = false;
        }      
    }
}